const path = require('path')

module.exports = {
  transpileDependencies: ['@dcloudio/uni-ui'],
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './'),
        '@/static': path.resolve(__dirname, './static')
      }
    }
  },
  chainWebpack: (config) => {
    // 处理字体文件
    config.module
      .rule('fonts')
      .test(/\.(woff2?|eot|ttf|otf)(\?.*)?$/i)
      .use('url-loader')
      .loader('url-loader')
      .options({
        limit: 4096,
        fallback: {
          loader: 'file-loader',
          options: {
            name: 'fonts/[name].[hash:8].[ext]'
          }
        }
      })
  },
  // H5开发环境代理配置
  devServer: {
    proxy: {
      '/api': {
        target: 'http://localhost:8082',
        changeOrigin: true,
        secure: false,
        logLevel: 'debug'
      },
      '/user': {
        target: 'http://localhost:8082',
        changeOrigin: true,
        secure: false,
        logLevel: 'debug'
      }
    }
  }
}
